<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title> 售房信息查看 </title>
    <meta http-equiv="Cache-Control" content="no-transform ">
    <meta name="applicable-device" content="pc">

    <!--TODO 新增：页面主样式-->
    <link rel="stylesheet" th:href="@{/css/index_v20210119153832.css}">

    <link type="text/css" rel="stylesheet" th:href="@{/css/CompontsLoader_v20190402152128.css}" media="all">

    <link id="dynamic-style" rel="stylesheet" charset="utf-8" media="all" type="text/css" th:href="@{/css/main.css}">
    <link th:href="@{/css/rent_pic_style.css}" type="text/css" rel="stylesheet" />

    <link rel="stylesheet" type="text/css" th:href="@{/css/bmaps.css}">
    <link rel="stylesheet" th:href="@{/css/commercial_peg_v20191017170251.css}">
    <link rel="stylesheet" th:href="@{/layuiadmin/layui/css/layui.css}" media="all">
    <style type="text/css">

        .layui-form-label {
        width: 80px;
        }

        .rentHouseInfoList{
            position: relative ;
            width: 1300px;
            left: 150px;
            height: auto;
            margin-bottom: 30px;
        }

        .rentHouseTitle{
            position: relative ;
            height: 50px;
            width: 300px;
            left: 164px;
            margin-top: 10px;
        }
        .titleSpan{
            font-size: 38px;
            /*Sans-serif*/
            font-family:幼圆 ;
        }
    </style>
</head>


<body>
<!-- 导航条 -->
<div id="commonTopbar" class="commonTopbar" style="min-width: 1190px;">
    <div class="w pos">
        <div class="bar_left">
            <h2>南阳</h2>&nbsp;&nbsp;&nbsp;&nbsp;
        </div>

        <div id="commonTopbar_homepageLink">
            <strong>
                <a class="mytxt" href="/yju/index" target="_self" >首页</a>
            </strong>
        </div>

        <input type="hidden" name="id" id="userId"    th:value="${session.commonUser?.id}">
        <input type="hidden" name="username" id="username"   th:value="${session.commonUser?.username}">
        <div class="bar_right">
            <div id="commonTopbar_login">
            </div>
            <div id="commonTopbar_my58menu" class="haschild">
                <a id="commonTopbar_tomy58"
                   target="_self"
                   href="javascript:;">个人中心</a>
                <span class="arrow"></span>
                <span class="mark"></span>
                <div class="hc" id="commonTopbar_loginbox">
                    <a href="/yju/personInfo" target="_self"> 信息修改</a>
                    <a href="/yju/passwordReset" target="_self"> 重置密码</a>
                    <a href="/yju/rentHouseInfoList" target="_self">租房信息</a>
                    <a href="/yju/sellHouseInfoList" target="_self">售房信息</a>
                </div>
            </div>

            <div id="commonTopbar_vip" class="haschild">
                <a class="mytxt" href="javascript:;" target="_self">
                    发布房源
                </a>
                <span class="arrow"></span>
                <span class="mark"></span>
                <div class="hc">
                    <a href="/yju/publishRentHouseInfo" target="_self">发布租房</a>
                    <a href="/yju/publishSellHouseInfo" target="_self">发布售房</a>
                </div>
            </div>

        </div>
    </div>
</div>

<div class="rentHouseTitle">
    <span class="titleSpan">售房信息查看</span>
</div>


<!--表单-->
<div class="rentHouseInfoList">
    <div class="layui-card-body">
        <table id="table" lay-filter="table"></table>

    </div>
</div>


<script th:src="@{/layuiadmin/layui/layui.js}"></script>

<script type="text/html" id="table_admin">
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail"><i class="fa fa-file-text-o"></i>详细查看</a>
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="fa fa-pencil"></i>编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="fa fa-trash-o"></i>删除</a>
</script>

<script type="text/javascript">

    layui.use(['jquery','layer', 'table'], function () {
        var table = layui.table;
        var layer = layui.layer;
        var $ = layui.jquery;

        //执行一个 table 实例
        table.render({
            elem: '#table',
            height: 400,
            width:1300,
            url: '/sellHouse/sellHouseListBelongUser', //数据接口
            title: '卖房信息列表',
            page: true,
            limit: 5,
            limits: [5,10,15,20],
            toolbar: true,
            cols: [
                [ //表头
                    {title: '序号',templet: '#indexTpl',width:60},
                    {field: 'title', title: '标题', width:249},
                    {field: 'linkman', title: '联系人', width: 80},
                    {field: 'region', title: '地区', width:70},
                    {field: 'housingEstate', title: '小区', width:110},
                    {field: 'nature', title: '产权', width: 90},
                    {field: 'type', title: '房屋类型', width: 90},
                    {field: 'decoration', title: '装修情况', width: 90},
                    {field: 'orientation', title: '朝向', width: 60},
                    {field: 'floorLevel', title: '楼层', width: 60},
                    {field: 'publishTime', title: '发布时间', width: 110},
                    {fixed: 'right',title:'操作', width: 220, align:'center', toolbar: '#table_admin'}
                ]
            ]
        });


        table.on('tool(table)', function(obj){ //注：tool 是工具条事件名，table 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            if(layEvent === 'edit'){
                edit(data);
            } else if(layEvent === 'del'){
                layer.confirm('真的删除行么', function(index){
                    del(data,obj,index);
                });
            }else if( layEvent == 'detail'){
                detail(data)
            }
        });

        function edit(data) {
            layer.open({
                type: 2,
                title: '修改卖房信息',
                skin: 'layui-layer-demo', //加上边框
                area: ['750px', '700px'], //宽高
                method: 'post',
                content: '/sellHouse/addSellHouse?type=edit&id='+data.id
            });
        }

        function detail(data) {
            layer.open({
                type: 2,
                title: '查看详细信息信息',
                skin: 'layui-layer-demo', //加上边框
                area: ['750px', '700px'], //宽高
                method: 'post',
                content: '/sellHouse/detailSellHouse?id='+data.id
            });
        }

        //后边两个参数仅仅是因为要执行动态删除dom
        function del(data,obj,index){
            var jsonObj = {};
            jsonObj["ids[0]"] = data.id;
            $.ajax({
                url:'/sellHouse/delSellHouse',
                data:jsonObj,
                dataType:'json',
                type:'post',
                success:function (data) {
                    if (data.success){
                        obj.del(); //删除对应行（tr）的DOM结构
                        layer.msg(data.message);
                        layer.close(index);
                        // window.location.reload();

                    }else{
                        layer.msg(data.message);
                    }
                }
            })
        }



        $("#commonTopbar_my58menu").mouseover(function () {
            $("#commonTopbar_my58menu").addClass("hover")
            console.log("mouseover")
        })

        $("#commonTopbar_my58menu").mouseout(function () {
            $("#commonTopbar_my58menu").removeClass("hover")
            console.log("mouseout")
        })


        $("#commonTopbar_vip").mouseover(function () {
            $("#commonTopbar_vip").addClass("hover")
            console.log("mouseover")
        })

        $("#commonTopbar_vip").mouseout(function () {
            $("#commonTopbar_vip").removeClass("hover")
            console.log("mouseout")
        })

        $(function () {


            var username = $("#username").val()

            var login_html = ''
            if (username == '') {

                login_html = "<a href='/yju/login' target='_self' >登录</a>"
                    + "<span class='gap'>|</span>"
                    + "<a href='/yju/register' target='_self' >注册</a>"
            } else {
                login_html = "<span>" + username + "</span>"
                    + "<span class='gap'>|</span>"
                    + "<a href='/yju/logout'>退出</a>"
            }
            $("#commonTopbar_login").html(login_html)

        })


    });

</script>

<script type="text/html" id="indexTpl">
    {{d.LAY_TABLE_INDEX+1}}
</script>

</body>
</html>
